﻿<?php
	function sendmail($addressto ,$mauser , $activecode)
	{
		global $successful ;
		require_once('class.phpmailer.php');
		
		$mail             = new PHPMailer();

		$mail->IsSMTP(); // telling the class to use SMTP
		$mail->SMTPAuth   = true;                  // enable SMTP authentication
		$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
		$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
		$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
		$mail->Username   = "groupb1.ctlh@gmail.com";  // GMAIL username
		$mail->Password   = "congtyluhanhgroupb1";            // GMAIL password

		$mail->SetFrom('groupb1.ctlh@gmail.com', 'ShoppingBook');

		$mail->AddReplyTo("groupb1.ctlh@gmail.com","First Last");

		$mail->Subject    = "Kich hoat tai khoan";


		$mail->AddAddress($addressto , "");
		
		$message = "Bạn đã đăng kí thành công. Vui lòng vào link sau để kích hoạt tài khoản." ;
		$message .= "http://localhost:8080/VieBook/index.php?com=user&fun=activeaccount&mauser=$mauser&activecode=$activecode" ;
		$mail->Body = $message ;


		if(!$mail->Send()) {
			return 0;
		} else {
			return 1;
		}
		
	}
	
	function resetpass($addressto ,$tendangnhap)
	{
		global $successful ;
		require('class.phpmailer.php');
		
		$mail             = new PHPMailer();

		$mail->IsSMTP(); // telling the class to use SMTP
		$mail->SMTPAuth   = true;                  // enable SMTP authentication
		$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
		$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
		$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
		$mail->Username   = "groupb1.ctlh@gmail.com";  // GMAIL username
		$mail->Password   = "congtyluhanhgroupb1";            // GMAIL password

		$mail->SetFrom('groupb1.ctlh@gmail.com', 'ShoppingBook');

		$mail->AddReplyTo("groupb1.ctlh@gmail.com","First Last");

		$mail->Subject    = "Tài Khoản ShoppingBook";

		$mail->AddAddress($addressto , "");
		
		$message = "Tài Khỏan của bạn: \n" ;
		$message .= " 	User: $tendangnhap \n" ;
		$message .= " 	Pass: $tendangnhap \n" ;
		$mail->Body = $message ;

		if(!$mail->Send()) {
			return 0;
		} else {
			return 1;
		}
		
	}
?>	
			
				
			
		
	
